$(function () {
    //1点击标题复选框表示全选
    $("#mec-head-checkbox").on("click", function () {
        // alert("执行通过账号找回密码的方法");
        // alert("密码是123");
        judgement();
    });

    function judgement() {
        var isChecked = $("#mec-head-checkbox").prop("checked");
        if (isChecked == true) {
            // $("#mec-head-checkbox").on("click",function () {
            //     judgement();
            $(".mec-content-checkbox").prop("checked", true);
            //});
        }
        else {
            //  $("#mec-head-checkbox").on("click",function () {
            //     judgement();
            $(".mec-content-checkbox").prop("checked", false);
            // });
        }
    }

    getDataList();

    function getDataList() {
        $.ajax({
            url: "/hospital/test.action",
            dataType: "json",
            success: function (data) {
                var $dataList = $(".list .phyexam_table");
                // console.log($dataList);
                $.each(data, function (index, ele) {
                    // console.log(ele);
                    var $item = creatDataItem(index, ele);
                    // console.log($item);
                    $dataList.append($item);
                });
            },
            error: function (e) {
                console.log(e);
            }
        });
    }

    function creatDataItem(index, data) {
        var $item = $("" +
            "<tr>\n" +
            "            <td><input type=\"checkbox\" class=\"mec-content-checkbox\"></td>\n" +
            "            <td class=\"phyexam\">"+(index+1)+"</td>\n" +
            "            <td class=\"phyexam\">"+data.stuNum+"</td>\n" +
            "            <td class=\"phyexam\">"+data.stuName+"</td>\n" +
            "            <td class=\"phyexam\">"+data.stuSex+"</td>\n" +
            "            <td class=\"phyexam\">"+data.phyExmNation+"</td>\n" +
            "            <td class=\"phyexam\">"+data.phyExmAge+"</td>\n" +
            "            <td class=\"phyexam\">"+data.departName+"</td>\n" +
            "            <td class=\"phyexam\">"+data.stuContactInfo+"</td>\n" +
            "            <td class=\"phyexam\">"+data.phyExmMedicalHistory+"</td>\n" +
            "            <td class=\"phyexam\">"+data.phyExmBirthPlace+"</td>\n" +
            "            <td class=\"phyexam\">"+data.proName+"</td>\n" +
            "            <td class=\"phyexam\">"+data.phyExmConclusion+"</td>\n" +
            "            <td class=\"phyexam\">"+data.phyExmPhysician+"</td>\n" +
            "        </tr>");
        return $item;
    }
});